<?php
/* 
Template Name: Homepage
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>charset=<?php bloginfo('charset'); ?>" />
<meta name="distribution" content="global" />
<meta name="geo.position" content="10.475602; 106.403980″ />
<meta name="geo.posion" content="VN-Hanoi" />
<meta name="robots" content="index, follow" />
<?php
$the_id = $GLOBALS['post']->ID;
$post = get_post($the_id, OBJECT);
$keywords = get_post_meta($the_id, 'keywords', true);
$description = get_post_meta($the_id, 'description', true);
$title = get_post_meta($the_id, 'title', true);
?>
<title>
<?php
if($title){
 echo $title;
}
else{
 echo $post->post_title." | FancyDesign";
}
?>
</title>
<link rel="icon" href="<?php echo bloginfo('stylesheet_directory'); ?>/images/logo-title.png" type="image/png">
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />

<meta name="description" content="<?php
if($description){
 echo $description;
}
else{
 echo 'Defauft';
}
?>">

<meta name="keywords" content="<?php
if($keywords){
 echo $keywords;
}
else{
 echo 'Defauft';
}
?>">
<link rel="icon" href="<?php echo bloginfo('stylesheet_directory'); ?>/images/logo-title.png" type="image/png">
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />

<link rel="icon" href="<?php echo bloginfo('stylesheet_directory'); ?>/images/logo-title.png" type="image/png">
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory');?>/style.css" />
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
$(window).ready(function() {
	$('#slider').nivoSlider({
		effect:'fade'
	});
	
	
});
</script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jcarousellite_1.0.1.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.easing.1.1.js"></script>
<script type="text/javascript">
$(function() {

	$('.nivo-caption').css("display","none");

	$('#slider').hover(
		function(){
			$('.nivo-caption').css("display","block");
		},
		function(){
			$('.nivo-caption').css("display","none");
		}
	);

	$("#home-slider").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible : 4,
		auto : 10000,
		speed : 1000,
		circular : true,
		scroll : 4
	});
});
</script>
</head>

<body class="home">
    <div class="wrapper-home">
    	<div class="home-header">
            <div class="logo">
				<a href="<?php echo(get_page_link(get_page_by_title('Home')->ID)) ?> ">
					<img src="<?php echo bloginfo('stylesheet_directory'); ?>/images/logo.png" />
				</a>
            </div>
            <div class="menu">
                <ul>
                    <?php 
                        $my_pages = wp_list_pages('echo=0&title_li=&exclude_tree=218');
                        $var1 = '<a';
                        $var2 = '<span><a';
                        $var3 = '</a';
                        $var4 = '</a></span';
                        $my_pages = str_replace($var1, $var2, $my_pages);
                        $my_pages = str_replace($var3, $var4, $my_pages);
                        echo $my_pages;
                    ?>
                </ul>
            </div>
        </div><!--end .home-header-->
        <div class="rightbar">
            <div class="slider-wrapper theme-default">
                <?php if (function_exists('nivoslider4wp_show')) { nivoslider4wp_show(); } ?>
            </div>
        </div>
       	<div class="more-products">
        	<div class="more-products-inner-shadow"></div>
            <div class="more-products-content">
                <a href="#"><div class="prev"></div></a>
                <a href="#"><div class="next"></div></a>
            	<div id="home-slider">
                    <ul>
                    	<?php 
						$products = new WP_query();
						$products->query("cat=3");
						if($products->have_posts()) : while($products->have_posts()) : $products->the_post();
						?>
						<li>
							<a href="<?php echo the_permalink(); ?>">
								<?php
									if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
										thumb_img($post->ID,'80','160','100',get_the_title());
									}
									else {?>
									<img class="item-thumbs" src="<?php echo bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo bloginfo('stylesheet_directory'); ?>/images/no-thumbnail.png&h=80&w=160&zc=1&q=100" alt=""/>
									<p><?php the_title(); ?></p> 
								<?php } ?>      
							</a>
						</li>
							<?php endwhile;?>
							<?php else : ?>
								<p>sorry, no post to display</p>
						<?php endif; ?>
                    </ul>
               	</div>
            </div> 
        </div>
    </div>
</body>
</html>
